proj := /home/mano/Dev/Projects/manoray

compiler := g++
optionalflags := -g -Wall
outflag := -o
compileflag := -c

shared := /usr/lib/libX11.so
objects := main.o Scene.o ViewPlane.o Ray3D.o Object3D.o HitInfo.o Light3D.o Surface.o Sphere3D.o Plane3D.o Vector3D.o Matrix4x4.o Color.o Material.o MWindow.o MWindowNative.o

incl := $(proj)/include
src := $(proj)/src
obj := $(proj)/obj

VPATH := $(obj):$(incl):$(src)

manoray.exe: $(objects)
	@echo "\nLinking" $@
	@$(compiler) $(optionalflags) $(outflag) $@ $(obj)/*.o $(shared)
	@echo "\nBUILD SUCCESSFUL!\n"

main.o: main.cpp MWindow.h
	@echo "Compiling" $@
	@$(compiler) $(optionalflags) $(outflag) $(obj)/$@ $(compileflag) $(src)/main.cpp -I $(incl)

Scene.o: Scene.h Scene.cpp ISurface.h ViewPlane.h Light3D.h Vector3D.h
	@echo "Compiling" $@
	@$(compiler) $(optionalflags) $(outflag) $(obj)/$@ $(compileflag) $(src)/Scene.cpp -I $(incl)

ViewPlane.o: ViewPlane.h ViewPlane.cpp ProjectionMode.h Vector3D.h Ray3D.h
	@echo "Compiling" $@
	@$(compiler) $(optionalflags) $(outflag) $(obj)/$@ $(compileflag) $(src)/ViewPlane.cpp -I $(incl)

Ray3D.o: Ray3D.h Ray3D.cpp Object3D.h
	@echo "Compiling" $@
	@$(compiler) $(optionalflags) $(outflag) $(obj)/$@ $(compileflag) $(src)/Ray3D.cpp -I $(incl)

Object3D.o: Object3D.h Object3D.cpp Matrix4x4.h
	@echo "Compiling" $@
	@$(compiler) $(optionalflags) $(outflag) $(obj)/$@ $(compileflag) $(src)/Object3D.cpp -I $(incl)

HitInfo.o: HitInfo.h HitInfo.cpp Vector3D.h
	@echo "Compiling" $@
	@$(compiler) $(optionalflags) $(outflag) $(obj)/$@ $(compileflag) $(src)/HitInfo.cpp -I $(incl)

Light3D.o: Light3D.h Light3D.cpp Object3D.h
	@echo "Compiling" $@
	@$(compiler) $(optionalflags) $(outflag) $(obj)/$@ $(compileflag) $(src)/Light3D.cpp -I $(incl)

Surface.o: Surface.h Surface.cpp ISurface.h Material.h Vector3D.h Color.h HitInfo.h Object3D.h Light3D.h Ray3D.h
	@echo "Compiling" $@
	@$(compiler) $(optionalflags) $(outflag) $(obj)/$@ $(compileflag) $(src)/Surface.cpp -I $(incl)

Sphere3D.o: Sphere3D.h Sphere3D.cpp Surface.h
	@echo "Compiling" $@
	@$(compiler) $(optionalflags) $(outflag) $(obj)/$@ $(compileflag) $(src)/Sphere3D.cpp -I $(incl)

Plane3D.o: Plane3D.h Plane3D.cpp Surface.h
	@echo "Compiling" $@
	@$(compiler) $(optionalflags) $(outflag) $(obj)/$@ $(compileflag) $(src)/Plane3D.cpp -I $(incl)

Vector3D.o: Vector3D.h Vector3D.cpp
	@echo "Compiling" $@
	@$(compiler) $(optionalflags) $(outflag) $(obj)/$@ $(compileflag) $(src)/Vector3D.cpp -I $(incl)

Matrix4x4.o: Matrix4x4.h Matrix4x4.cpp Vector3D.h
	@echo "Compiling" $@
	@$(compiler) $(optionalflags) $(outflag) $(obj)/$@ $(compileflag) $(src)/Matrix4x4.cpp -I $(incl) 

Color.o: Color.h Color.cpp
	@echo "Compiling" $@
	@$(compiler) $(optionalflags) $(outflag) $(obj)/$@ $(compileflag) $(src)/Color.cpp -I $(incl)

Material.o: Material.h Material.cpp Color.h Light3D.h
	@echo "Compiling" $@
	@$(compiler) $(optionalflags) $(outflag) $(obj)/$@ $(compileflag) $(src)/Material.cpp -I $(incl)

MWindow.o: MWindow.h MWindow.cpp Scene.h Sphere3D.h Plane3D.h
	@echo "Compiling" $@
	@$(compiler) $(optionalflags) $(outflag) $(obj)/$@ $(compileflag) $(src)/MWindow.cpp -I $(incl)

MWindowNative.o: MWindow.h MWindow.cpp MWindowNative.cpp
	@echo "Compiling" $@
	@$(compiler) $(optionalflags) $(outflag) $(obj)/$@ $(compileflag) $(src)/MWindowNative.cpp -I $(incl)

.PHONY: clean
clean:
	@rm manoray.exe $(obj)/*.o
